@extends('layouts.template')

@section('title', '管理后台')

@section('content')

    <script>
        $(function(){

            var form = new Vue({
                el:'#contentpanel',
                data:{
                },
                computed:{
                },
                mounted:function(){
                },
                watch: {
                },
                methods:{
                },
                components:{
                }
            });

            window.showImage = function(source)
            {
                $("#detail").find(".modal-content").html("<image src='"+source+"' width='100%' />");
                $("#detail").modal('show');
            }

            $("#detail").on("hidden.bs.modal", function(event) {
                $(this).removeData("bs.modal");
                $(this).find('.modal-content').empty();
            });

            $("#disable").on("show.bs.modal", function(event) {
                var button = $(event.relatedTarget);
                var modal = $(this);
                modal.find('[name=master_id]').val(button.data('id'));
            });

            var validator = $("#disable-form").validate({
                rules: {
                    master_id:{
                        required:true,
                    },
                    disable_type:{
                        required:true,
                    },
                    disable_time:{
                        required:function(){
                            return $('[name=disable_type]:checked').val() == '{{$disable_temporary}}';
                        },
                        digits:true,
                        min:1,
                    },
                },
                messages: {
                    master_id:{
                        required:'缺少师傅id',
                    },
                    disable_type:{
                        required:'请选择停单类型',
                    },
                    disable_time:{
                        required:'请输入临时停单天数',
                    },
                },
                submitHandler: function(form) {
                    form.submit();
                },
            });
        });

    </script>

    <div class="panel-body">
        <div class="panel panel-default">
            <div class="panel-body">
                <form action="" method="GET" class="form-inline">
                    <div>
                        {!! $filter !!}
                    </div>
                </form>
            </div>
        </div>
    </div>

    <div class="contentpanel" id="contentpanel">

        <div class="row">
            <div class="col-md-12">
                <div class="table-responsive">
                    <table class="table mb30">
                        <thead>
                        <tr style="white-space:nowrap">
                            <th>入驻时间</th>
                            <th>师傅名字</th>
                            <th>手机号码</th>
                            <th>所在省市区</th>
                            <th>服务类型</th>
                            <th>质保金</th>
                            <th>身份证照片</th>
                            <th>入驻审核</th>
                            {{--<th>头像审核</th>--}}
                            <th>师傅钱包</th>
                            <th>停单操作</th>
                            <th>师傅详情</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php foreach ($list as $row):?>
                            <tr data-id="{{$row->id}}">
                                <td>{{$row->add_time}}</td>
                                <td>{{$row->real_name}}</td>
                                <td>{{$row->phone}}</td>
                                <td>{{$row->area_text}}</td>
                                <td>{{$row->service_type_text}}</td>
                                <td>
                                    @if ($row->wallet->assure_fund)
                                        已缴纳
                                    @else
                                        未缴纳
                                    @endif
                                </td>
                                <td>
                                    <button onclick="showImage('{{$row->idcard_front_url}}')" class="btn btn-white">正面</button>
                                    <button onclick="showImage('{{$row->idcard_back_url}}')" class="btn btn-white">背面</button>
                                    <button onclick="showImage('{{$row->idcard_hold_url}}')" class="btn btn-white">半身</button>
                                </td>
                                <td>
                                    @if ($row->waiting_pass)
                                        <a onclick="return confirm('注册通过审核')" href="{{url("master/registerpass/{$row->id}")}}" class="btn btn-white">待审核</a>
                                    @else
                                        已审核
                                    @endif
                                </td>
                                <td>
                                    {{--@if ($row->detail->head_chang_to)
                                        <button onclick="showImage('{{$row->detail->head_chang_to}}')" class="btn btn-white">头像</button>
                                        <a onclick="return confirm('头像通过审核')" href="{{url("master/headimgpass/{$row->id}")}}" class="btn btn-warning">待审核</a>
                                    @elseif (!$row->head_img)
                                        无头像
                                    @else
                                        已审核
                                    @endif--}}
                                    <a href="{{url("ajax/master/wallet/{$row->id}")}}" class="btn btn-white" data-toggle="modal" data-target="#detail">查看钱包</a>
                                </td>
                                <td>
                                    @if ($row->disabled)
                                        <a onclick="return confirm('将师傅解除停单')" href="{{url("master/enable/{$row->id}")}}" class="btn btn-danger">已停单</a>
                                    @else
                                        <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#disable" data-id="{{$row->id}}">停单</button>
                                    @endif
                                </td>
                                <td><a href="{{url("ajax/master/detail/{$row->id}")}}" class="btn btn-white" data-toggle="modal" data-target="#detail">查看</a></td>
                                <td>
                                    <a onclick="return confirm('再次确认删除该师傅')" href="{{url("master/delmaster/{$row->id}")}}" class="btn btn-danger">删除</a>
                                </td>
                            </tr>
                        <?php endforeach;?>
                        </tbody>
                    </table>
                </div>
                <!-- table-responsive -->
                {{ @!$list->isEmpty() ? $list->appends(request()->all())->links() : '' }}
            </div>
            <!-- col-md-12 -->
        </div>
    </div><!-- contentpanel -->

    <div class="modal fade" id="detail" tabindex="-1" role="dialog" data-keyboard="false">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
            </div>
        </div>
    </div>


    <div class="modal fade" id="disable" tabindex="-1" role="dialog" data-keyboard="false">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">停单</h4>
                </div>
                <form id="disable-form" method="post" action="{{url("master/disable")}}">
                    {{csrf_field()}}
                    <input type="hidden" name="master_id">
                    <div class="modal-body">
                        <div class="form-group">
                            <div class="col-sm-9">
                                <div class="radio"><label><input type="radio" name="disable_type" value="{{$disable_forever}}"> 永久停单</label></div>
                            </div>
                            <div class="col-sm-9">
                                <div class="radio"><label><input type="radio" name="disable_type" value="{{$disable_temporary}}"> 临时停单</label>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;停单<input type="text" name="disable_time">天</div>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="submit" class="btn btn-primary">确定</button>
                    </div>
                </form>
            </div>
        </div>
    </div>


@endsection

